-
Notifications
You must be signed in to change notification settings - Fork 233
Add function $uuid() #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add function $uuid() #731
Conversation
Doesn't like node 16 either (also out of service) |
Generates a random UUID (version 4) Signed-off-by: Andrew Coleman <[email protected]>
Node.js 16 went out of support last April, and was a reason for a lot of npm modules doing major version bumps through the summer as they also removed support. We should also be doing a major version bump if we're dropping support for older versions, as per semver (it's a breaking change). Node.js 18 is still in support until end of April this year, so would be reluctant to want to drop it at this point. |
I agree, and as I've just discovered, this new function was included in Node from v19. So I think we should hold off from adding this at the moment. https://developer.mozilla.org/en-US/docs/Web/API/Window/crypto |
Would you consider writing your own uuid function, so that you don't need to use this crypto library? AFAIK, there's no actual cryptography to it, only random number generation and bitwise operators. When I first found jsonata, I implemented UUID 4 with a jsonata expression:
|
Thanks @markmelville, yes I started off with this approach, but the specification for UUIDv4 says that it should use a cryptographically secure random number generator, which led me to the https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-4 |
But crazy ideas start small only to either fail or become big, either way it's worth a try. The intention of the JSONata parser is to transform JSONata into Erlang code that can then be executed either at runtime or precompiled before executing the flow code. Also the set of valid JSONata stanzas that will be convertible will be the set that I need[1] - this being a very much smaller set than all valid JSONata[2]. I'm sure this approach is a deadend since JSONata can become extremely complex and conversion to Erlang will be messy and complex but its an approach that can be quickly and dirtily implemented. Plus, in the process, the learnings of playing around with leex and yecc are well worth it: niche concepts (parser construction), in a niche programming language (Erlang) for a niche problem space (JSONata) and the whole thing applied to a niche development concept (visual FBP)! :) [1]: https://github.com/gorenje/erlang-red/blob/40b489e9491d6f1ef38218838e21c0d85f6f0e30/priv/jsonata/leex.examples.json [2]: jsonata-js/jsonata#731 (comment)
Generates a random UUID (version 4)
Uses the crypto.randomUUID() implementation which has been available in node since v16. Hence, removing v12 & v14 from the CI (these are long out of service anyway).